class TemporalModelChangedTooFast(Exception):
    "The temporal object changed too fast"

    def __init__(self, old_instance, days_passed, min_days_between_changes):
        self.messages = "%s '%s' was last changed %d days ago (min %d days between changes)" % (
                old_instance._meta.object_name,
                old_instance,
                days_passed,
                min_days_between_changes
        )

    def __str__(self):
        # This is needed because, without a __str__(), printing an exception
        # instance would result in this:
        # AttributeError: TemporalModelChangedTooFast instance has no attribute 'args'
        # See http://www.python.org/doc/2.5/tut/node10.html#handling
        return repr(self.messages)


class TemporalModelHasNotChanged(Exception):
    "The temporal object has not changed"

    def __init__(self, old_instance):
        self.messages = "%s '%s' is no different from its previous version" % (
                old_instance._meta.object_name,
                old_instance,
        )

    def __str__(self):
        # This is needed because, without a __str__(), printing an exception
        # instance would result in this:
        # AttributeError: TemporalModelChangedTooFast instance has no attribute 'args'
        # See http://www.python.org/doc/2.5/tut/node10.html#handling
        return repr(self.messages)
